<template>
  <div>
    <el-form
      ref="vehicleForm"
      :model="form"
      label-width="90px"
    >
      <el-row>
        <el-col :md="7" :lg="7">
          <el-form-item label="车牌号:">
            <el-input
              v-model="form.num"
              size="medium"
              placeholder="请输入车牌号"
            />
          </el-form-item>
        </el-col>
        <el-col :md="7" :lg="7">
          <el-form-item label="车辆品牌:">
            <el-select
              v-model="form.cartype0"
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="item in CarNameList()"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :md="7" :lg="7">
          <el-form-item label="车辆类型:">
            <el-select
              v-model="form.cartype1"
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="item in CarTypeList()"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :md="3" :lg="3" style="text-align: right">
          <!-- <el-form-item> -->
          <el-button
            type="primary"
            size="medium"
            style="float: right"
            @click="onSubmit('vehicleForm')"
          >
            搜索
          </el-button>
          <!-- </el-form-item> -->
        </el-col>
      </el-row>
      <el-row>
        <el-col :md="9" :lg="7">
          <el-form-item label="首登日期:">
            <el-date-picker
              v-model="form.regdate"
              type="date"
              size="medium"
              placeholder="请选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
        </el-col>
        <el-col :md="9" :lg="7">
          <el-form-item label="年审日期:">
            <el-date-picker
              v-model="form.yearcare"
              type="date"
              size="medium"
              placeholder="请选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
        </el-col>
        <el-col :md="10" :lg="7">
          <el-form-item label="交强险日期:">
            <el-date-picker
              v-model="form.yearinsure0"
              type="date"
              size="medium"
              placeholder="请选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
        </el-col>
        <el-col :md="10" :lg="7">
          <el-form-item label="商业险日期:">
            <el-date-picker
              v-model="form.yearinsure"
              type="date"
              size="medium"
              placeholder="请选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import mixin from '@/mixin/mixin'

export default {
  name: 'VehicleForm',
  mixins: [mixin],
  data() {
    return {
      form: {
        num: '',
        cartype0: '',
        cartype1: '',
        regdate: '',
        yearcare: '',
        yearinsure0: '',
        yearinsure: ''
      }
    }
  },
  methods: {
    onSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('on-success-valid', {
            num: this.form.num,
            cartype0: this.form.cartype0,
            cartype1: this.form.cartype1,
            regdate: this.form.regdate,
            yearcare: this.form.yearcare,
            yearinsure0: this.form.yearinsure0,
            yearinsure: this.form.yearinsure
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style scoped>
/* .el-date-editor.el-input, .el-date-editor.el-input__inner {
  width: 100%
} */
.el-input{
  width: 160px;
}
</style>
